package cn.wolfcode.web.controller;

import cn.wolfcode.domain.Appointment;
import cn.wolfcode.enums.AppointmentEnums;
import cn.wolfcode.qo.JsonResult;
import cn.wolfcode.service.IAppointmentService;
import cn.wolfcode.service.IBusinessService;
import cn.wolfcode.service.ISystemDictionaryItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/frontend")
public class IndexController {
    @Autowired
    private IBusinessService businessService;
    @Autowired
    private IAppointmentService appointmentService;
    @Autowired
    private ISystemDictionaryItemService systemDictionaryItemService;
    @RequestMapping("/index")
    public String index(Model model){
        model.addAttribute("mainStore",businessService.selectMainStore());
        //业务大类
        model.addAttribute("business",systemDictionaryItemService.queryBysn("business"));
        //门店
        model.addAttribute("store",businessService.listAll());
        return "/index";
    }

    @RequestMapping("/appointment/save")
    @ResponseBody
    public JsonResult save(Appointment appointment) {
        JsonResult result = new JsonResult();
        //前台录入状态
        appointment.setStatus(AppointmentEnums.PEND.getValue());
        appointmentService.save(appointment);
        return result;
    }
}
